<template>
  <avue-crud
    :option="option"
    :data="data"
    :page.sync="page"
     ref="crud" :before-open="beforeOpen" @row-save="handleSave" @row-update="handleUpdate"
  >
    <!-- <template slot-scope="scope" slot="menuLeft">
    <el-button type="danger" icon="el-icon-plus" size="small" plain @click.stop="handleAdd()">新增</el-button>
  </template>
   <template slot-scope="scope" slot="menuForm">
    <el-button type="primary" icon="el-icon-check" size="small" plain v-if="type=='add'" @click="$refs.crud.rowSave()">自定义新增</el-button>
    <el-button type="primary" icon="el-icon-check" size="small" plain v-if="type=='edit'" @click="$refs.crud.rowUpdate()">自定义修改</el-button>
   <el-button type="primary" icon="el-icon-check" size="small" plain @click="$refs.crud.closeDialog()">取消</el-button>
  </template>
  <template slot-scope="scope" slot="menu">
     <el-button type="primary" icon="el-icon-check" size="small" plain @click.stop="handleEdit(scope.row,scope.index)">编辑</el-button>
  </template> -->
  </avue-crud>
</template>


<script>
export default {
  data() {
    return {
      page: {
        total: 0,
      },
      option: {
        column: [
          {
            label: "姓名",
            prop: "name",
            type: "input",
            search: true,
    
          },
          {
            label: "年龄",
            prop: "age",
            type: "textarea",
            search: false,
            addDisplay: false,
            addDisabled: true,
            requierd: true,
          },
          {
            label: "性别",
            prop: "sex",
            type: "select",
            search: true,
          },
        ],
      },
      data: [
        {
          name: "qwe",
          age: 18,
          sex: "男",
        },
      ],
    };
  },
    methods:{
      // beforeOpen(done,type){
      //   this.type=type;
      //   done()
      // },
      // handleAdd(){
      //   this.$refs.crud.rowAdd();
      // },
      // handleSave(form,done,loading){
      //   this.$message.success('新增数据'+ JSON.stringify(form));
      // },
      // handleUpdate(form,index,done,loading){
      //   this.$message.success('编辑数据'+ JSON.stringify(form)+'数据序号'+index);
      // },
      // handleEdit (row, index) {
      //   this.$refs.crud.rowEdit(row, index);
      // },
    }
};
</script>